import { defineComponent, h } from 'vue';
import styles from '@/pages/MainMenu/common_page.module.scss';
import { createCommonDataTable, createCommonPagination } from '@/pages/MainMenu/common_component_creator';
import { AccountType } from '@/global';
import {
  createOperateActions,
  OperateButton,
  TableColumnConfig
} from '@/util/vnode_create_util/dynamic_table_column_creator';
import { windAccountListReactive } from '@/pages/MainMenu/User/WindAccount/WindAccountOperate';
export interface WindAccount{
  accountId: string;
  accountName: string;
  accountPassword: string;
  accountPasswordSalt: string;
  accountType: AccountType;
  accountTypeText: string;
  createById: string;
  createNickName: string;
  createByIp: string;
  createDate: string;
  loginDate: string;
  loginIp: string;
  updateById: string;
  updateNickName: string;
  updateByIp: string;
  updateDate: string;
  userId: string;
  userNickName: string;
}
// wind用户
const operateButtons: OperateButton<WindAccount>[] = [
  { title: '绑定', action: async (scope) => {}, isShow: () => true },
  { title: '删除', action: () => {}, isShow: () => true }
];

// 三年审核计划的列表组成配置参数
export const windAccountColumn: TableColumnConfig<WindAccount>[] = [
  { label: '账号名称', width: '140px', dom: scope => <div>{scope.row.accountName}</div> },
  { label: '账号类别', width: '100px', dom: scope => <div>{scope.row.accountTypeText}</div> },
  { label: '创建时间', width: '180px', dom: scope => <div>{scope.row.createDate}</div> },
  { label: '创建人', width: '180px', dom: scope => <div>{scope.row.createNickName}</div> },
  { label: '最近更新时间', width: '180px', dom: scope => <div>{scope.row.updateDate}</div> },
  { label: '最近更新人', width: '180px', dom: scope => <div>{scope.row.updateNickName}</div> },
  { label: '' },
  { label: '操作', width: '160px', fixed: 'right', dom: scope => <div>{createOperateActions(operateButtons, scope)}</div> }
];
export default defineComponent({
  name: 'WindAccount',
  setup () {
    const accountReactive = windAccountListReactive();
    return () => <div class={`${styles.page_container}`}>
      { createCommonDataTable({ data: accountReactive.dataList, loading: accountReactive.tableLoading, defineColumns: windAccountColumn }) }

      { createCommonPagination({ page: accountReactive.page, changePageFunction: accountReactive.onLoad })}
    </div>;
  }
});
